package com.ycy.smartcourseselection.exception;


import com.ycy.smartcourseselection.common.ResCodeEnum;

//自定义异常步骤：
//1.自定义异常类 需要继承 RuntimeException
public class CustomException extends RuntimeException{
    // 这个自定义异常类有两个属性，一个是code,一个是message。但 message是调用父类RuntimeException中的message
    private ResCodeEnum resCodeEnum;

    private String data;

    //有参构造
    public CustomException(ResCodeEnum resCodeEnum) {
        super(resCodeEnum.getMessage());
        this.resCodeEnum = resCodeEnum;
    }

    public CustomException(ResCodeEnum resCodeEnum,String message) {
        super(message);
        this.resCodeEnum = resCodeEnum;
    }

    public CustomException(ResCodeEnum resCodeEnum,String message,String data) {
        super(message);
        this.resCodeEnum = resCodeEnum;
        this.data = data;
        // System.out.println("CustomException---------"+ data);
        // System.out.println("CustomException  this---------"+ this.data);
    }



    public ResCodeEnum getResCodeEnum() {
        return resCodeEnum;
    }

    public String getData() { return data;}

    public void setResCodeEnum(ResCodeEnum resCodeEnum) {
        this.resCodeEnum = resCodeEnum;
    }
}

//2.新建一个异常处理类 MyExceptionHandler
